package easy

import (
	"strconv"
	"workspace/node"
)

var paths []string

func BinaryTreePaths(root *node.TreeNode) []string {
	paths = []string{}
	constructPaths(root, "")
	return paths
}
func constructPaths(root *node.TreeNode, path string) {
	if root != nil {
		pathSb := path
		pathSb += strconv.Itoa((root.Val))
		if root.Left == nil && root.Right == nil {
			paths = append(paths, pathSb)
		} else {
			pathSb += "->"
			constructPaths(root.Left, pathSb)
			constructPaths(root.Right, pathSb)
		}
	}
}
